package com.sky.service.user.impl;

import com.sky.constant.StatusConstant;
import com.sky.context.BaseContext;
import com.sky.mapper.user.DishMapper;
import com.sky.service.user.DishService;
import com.sky.vo.DishVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service("userDishService")
public class DishServiceImpl implements DishService {


    @Autowired
    private DishMapper dishMapper;
    /**
     * 根据分类id查询菜品
     *
     * @param categoryId
     * @return
     */
    @Override
    public List<DishVO> selectDishByCategoryId(Long categoryId) {
        List<DishVO> dishVOList = dishMapper.selectDishByCategoryId(categoryId);

        return dishVOList.stream().filter(dishVO -> Objects.equals(dishVO.getStatus(), StatusConstant.ENABLE)).collect(Collectors.toList());
    }
}
